1 <?php include ( "../inc/connect.inc.php" ); ?>
2 <?php
3 ob_start();
4 session_start();

5 if
(!isset($_SESSION['admin_login'])) {
6     header(
"location: login.php");
7     $user =
"";
8 }

9 else
{
10     $user = $_SESSION[
'admin_login'];
11     $result = mysql_query(
"SELECT * FROM admin WHERE id='$user'");
12         $get_user_email = mysql_fetch_assoc($result);
13             $uname_db = $get_user_email[
'firstName'];
14 }
15 $pname =
"";
16 $price =
"";
17 $available =
"";
18 $category =
"";
19 $type =
"";
20 $item =
"";
21 $pCode =
"";
22 $descri =
"";
23
24 if
(isset($_POST['signup'])) {
25 //declere veriable

26 $pname = $_POST[
'pname'];
27 $price = $_POST[
'price'];
28 $available = $_POST[
'available'];
29 $category = $_POST[
'category'];
30 $type = $_POST[
'type'];
31 $item = $_POST[
'item'];
32 $pCode = $_POST[
'code'];
33 $descri = $_POST[
'descri'];
34 //triming name

35 $_POST[
'pname'] = trim($_POST['pname']);
36
37 //finding file extention

38 $profile_pic_name = @$_FILES[
'profilepic']['name'];
39 $file_basename = substr($profile_pic_name,
0, strripos($profile_pic_name, '.'));
40 $file_ext = substr($profile_pic_name, strripos($profile_pic_name,
'.'));
41
42 if
(((@$_FILES['profilepic']['type']=='image/jpeg') || (@$_FILES['profilepic']['type']=='image/png') || (@$_FILES['profilepic']['type']=='image/gif')) && (@$_FILES['profilepic']['size'] < 1000000)) {
43
44     $item = $item;
45     
if (file_exists("../image/product/$item")) {
46         
//nothing
47     }
else {
48         mkdir(
"../image/product/$item");
49     }
50     
51     
52     $filename = strtotime(date(
'Y-m-d H:i:s')).$file_ext;
53
54     
if (file_exists("../image/product/$item/".$filename)) {
55         echo @$_FILES[
"profilepic"]["name"]."Already exists";
56     }
else {
57         
if(move_uploaded_file(@$_FILES["profilepic"]["tmp_name"], "../image/product/$item/".$filename)){
58             $photos = $filename;
59             $result = mysql_query(
"INSERT INTO products(pName,price,description,available,category,type,item,pCode,picture) VALUES ('$_POST[pname]','$_POST[price]','$_POST[descri]','$_POST[available]','$_POST[category]','$_POST[type]','$_POST[item]','$_POST[code]','$photos')");
60                 header(
"Location: allproducts.php");
61         }
else {
62             echo
"Something Worng on upload!!!";
63         }
64         
//echo "Uploaded and stored in: userdata/profile_pics/$item/".@$_FILES["profilepic"]["name"];
65         
66         
67     }
68     }
69     
else {
70         $error_message =
'Add picture!';
71     }
72 }
73 $search_value =
"";
74
75 ?>
76
77
78 <!doctype html>
79 <html>
80     <head>
81         <title>Welcome to ebuybd online shop</title>
82         <link rel=
"stylesheet" type="text/css" href="../css/style.css">
83     </head>
84     <body
class="home-welcome-text" style="background-image: url(../image/homebackgrndimg2.png);">
85         <div
class="homepageheader">
86             <div
class="signinButton loginButton">
87                 <div
class="uiloginbutton signinButton loginButton" style="margin-right: 40px;">
88                     <?php
89                         
if ($user!="") {
90                             echo
'<a style="text-decoration: none;color: #fff;" href="logout.php">LOG OUT</a>';
91                         }
92                      ?>
93                     
94                 </div>
95                 <div
class="uiloginbutton signinButton loginButton">
96                     <?php
97                         
if ($user!="") {
98                             echo
'<a style="text-decoration: none;color: #fff;" href="login.php">Hi '.$uname_db.'</a>';
99                         }
100                         
else {
101                             echo
'<a style="text-decoration: none;color: #fff;" href="login.php">LOG IN</a>';
102                         }
103                      ?>
104                 </div>
105             </div>
106             <div style=
"float: left; margin: 5px 0px 0px 23px;">
107                 <a href=
"index.php">
108                     <img style=
" height: 75px; width: 130px;" src="../image/ebuybdlogo.png">
109                 </a>
110             </div>
111             <div id=
"srcheader">
112                 <form id=
"newsearch" method="get" action="search.php">
113                         <?php
114                             echo
'<input type="text" class="srctextinput" name="keywords" size="21" maxlength="120" placeholder="Search Here..." value="'.$search_value.'"><input type="submit" value="search" class="srcbutton" >';
115                          ?>
116                 </form>
117             <div
class="srcclear"></div>
118             </div>
119         </div>
120         <div
class="categolis">
121             <table>
122                 <tr>
123                     <th>
124                         <a href=
"index.php" style="text-decoration: none;color: #fff;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Home</a>
125                     </th>
126                     <th><a href=
"addproduct.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #24bfae;border-radius: 12px;">Add Product</a></th>
127                     <th><a href=
"newadmin.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">New Admin</a></th>
128                     <th><a href=
"allproducts.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">All Products</a></th>
129                     <th><a href=
"orders.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Orders</a></th>
130                 </tr>
131             </table>
132         </div>
133         <?php
134             
if(isset($success_message)) {echo $success_message;}
135             
else {
136                 echo
'
137                     <div
class="holecontainer" style="float: right; margin-right: 36%; padding-top: 20px;">
138                         <div
class="container">
139                             <div>
140                                 <div>
141                                     <div
class="signupform_content">
142                                         <h2>Add Product Form!</h2>
143                                         <div
class="signup_error_msg">';
144                                             
if (isset($error_message)) {echo $error_message;}
145                                         echo
'</div>
146                                         <div
class="signupform_text"></div>
147                                         <div>
148                                             <form action=
"" method="POST" class="registration" enctype="multipart/form-data">
149                                                 <div
class="signup_form">
150                                                     <div>
151                                                         <td >
152                                                             <input name=
"pname" id="first_name" placeholder="Product Name" required="required" class="first_name signupbox" type="text" size="30" value="'.$pname.'" >
153                                                         </td>
154                                                     </div>
155                                                     <div>
156                                                         <td >
157                                                             <input name=
"price" id="last_name" placeholder="Price" required="required" class="last_name signupbox" type="text" size="30" value="'.$price.'" >
158                                                         </td>
159                                                     </div>
160                                                     <div>
161                                                         <td>
162                                                             <input name=
"available" placeholder="Available Quantity" required="required" class="email signupbox" type="text" size="30" value="'.$available.'">
163                                                         </td>
164                                                     </div>
165                                                     <div>
166                                                         <td >
167                                                             <input name=
"descri" id="first_name" placeholder="Description" required="required" class="first_name signupbox" type="text" size="30" value="'.$descri.'" >
168                                                         </td>
169                                                     </div>
170                                                     <div>
171                                                         <td>
172                                                             <
select name="category" required="required" style=" font-size: 20px;
173                                                         font-style: italic;margin-bottom: 3px;margin-top: 0px;padding: 14px;line-height: 25px;border-radius: 4px;border: 1px solid #
169E8F;color: #169E8F;margin-left: 0;width: 300px;background-color: transparent;" class="">
174                                                                 <option selected
value="women">Women</option>
175                                                             </
select>
176                                                         </td>
177                                                     </div>
178                                                     <div>
179                                                         <
select name="type" required="required" style=" font-size: 20px;
180                                                         font-style: italic;margin-bottom: 3px;margin-top: 0px;padding: 14px;line-height: 25px;border-radius: 4px;border: 1px solid #
169E8F;color: #169E8F;margin-left: 0;width: 300px;background-color: transparent;" class="">
181                                                                 <option selected
value="clothing">Clothing</option>
182                                                                 <option
value="other">Other</option>
183                                                             </
select>
184                                                     </div>
185                                                     <div>
186                                                         <td>
187                                                             <
select name="item" required="required" style=" font-size: 20px;
188                                                         font-style: italic;margin-bottom: 3px;margin-top: 0px;padding: 14px;line-height: 25px;border-radius: 4px;border: 1px solid #
169E8F;color: #169E8F;margin-left: 0;width: 300px;background-color: transparent;" class="">
189                                                                 <option selected
value="saree">Saree</option>
190                                                                 <option
value="ornament">Ornaments</option>
191                                                                 <option
value="watch">Watch</option>
192                                                                 <option
value="tshirt">T-Shirt</option>
193                                                                 <option
value="hijab">Hijab</option>
194                                                                 <option
value="perfume">Perfume</option>
195                                                                 <option
value="footwear">Footwear</option>
196                                                                 <option
value="toiletry">Toiletry</option>
197                                                             </
select>
198                                                         </td>
199                                                     </div>
200                                                     <div>
201                                                         <td>
202                                                             <input name=
"code" id="password-1" required="required" placeholder="Code" class="password signupbox " type="text" size="30" value="'.$pCode.'">
203                                                         </td>
204                                                     </div>
205                                                     <div>
206                                                         <td>
207                                                             <input name=
"profilepic" class="password signupbox" type="file" value="Add Pic">
208                                                         </td>
209                                                     </div>
210                                                     <div>
211                                                         <input name=
"signup" class="uisignupbutton signupbutton" type="submit" value="Add Product">
212                                                     </div>
213                                                 </div>
214                                             </form>
215                                             
216                                         </div>
217                                     </div>
218                                 </div>
219                             </div>
220                         </div>
221                     </div>
222                 
';
223             }
224
225          ?>
226     </body>
227 </html>


Gõ tìm kiếm nhanh...